package com.hippo.core.controller;

import com.alibaba.fastjson.JSONObject;
import com.hippo.core.config.annotation.RequiresPermissions;
import com.hippo.core.service.ElementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: hippo
 */
@RestController
public class ElementController {

    @Autowired
    private ElementService elementService;

    @RequiresPermissions("element:list")
    @PostMapping("/getElementList")
    public JSONObject getElementList(@RequestBody JSONObject obj) {
        return elementService.getElementList(obj);
    }

    @PostMapping("/getAllElementList")
    public JSONObject getAllElementList(@RequestBody JSONObject obj) {
        return elementService.getAllElementList(obj);
    }

    @RequiresPermissions("element:add")
    @PostMapping("/addElement")
    public JSONObject addElement(@RequestBody JSONObject obj) {
        return elementService.addElement(obj);
    }

    @RequiresPermissions("element:update")
    @PutMapping("/updateElement")
    public JSONObject updateElement(@RequestBody JSONObject obj) {
        return elementService.updateElement(obj);
    }

    @RequiresPermissions("element:delete")
    @DeleteMapping("/deleteElement/{id}")
    public JSONObject addElement(@PathVariable String id) {
        return elementService.deleteElement(id);
    }

}
